//
//  ButtonView.m
//  吃货·上海
//
//  Created by 濮亚军 on 15/11/24.
//  Copyright © 2015年 濮亚军. All rights reserved.
//

#import "ButtonView.h"

@interface ButtonView()

//底部点击页面的的图片
@property(nonatomic, strong)UIImageView *buttonImageView;

//底部点击页面的标题
@property(nonatomic, strong)UILabel *buttonName;

@end

@implementation ButtonView

//重写初始化方法 根据图片和标题来创建buttonView
-(instancetype)initWithFrame:(CGRect)frame iamge:(UIImage *)image title:(NSString *)title
{
    self = [super initWithFrame:frame];
    if (self)
    {
        //[self.layer setBorderWidth:1];
        
        CGFloat y = frame.size.height - 30;
        CGFloat x = (frame.size.width - y) / 2;
        self.buttonImageView = [[UIImageView alloc]initWithFrame:CGRectMake(x, 8, y, y)];
        //self.buttonImageView.backgroundColor = [UIColor cyanColor];
        self.buttonImageView.image = image;
        [self addSubview:_buttonImageView];
        
        self.buttonName = [[UILabel alloc]initWithFrame:CGRectMake(x - 2.5, y + 13, y + 5, 15)];
        self.buttonName.textAlignment = NSTextAlignmentCenter;
        //self.buttonName.backgroundColor = [UIColor redColor];
        self.buttonName.font = [UIFont systemFontOfSize:12];
        self.buttonName.text = title;
        [self addSubview:_buttonName];
    }
    return self;
}

@end
